<template>
	<view class="home">
		<view class="uni-padding-wrap uni-common-mt">
			<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" />
		</view>
		<view class="content">
			<view v-if="current === 0">
				<view class="active-body">
					<view class="active-body-item" v-for="v in notice" :key="v.id">
						<view class="item-box"> </view>
						<view class="item-text">
							<view class="top">
								<text>{{v.noticeTitle}}</text>
							</view>
							<view class="item-state">
								<text>{{v.urgencyName}}</text>
							</view>
							<view class="bottom">
								<text>物业服务中心 {{v.date}}</text>
							</view>
						</view>
					</view>
				</view>
				</text>
			</view>
			<view v-if="current === 1">
				<view class="active-body">
					<view class="active-body-item" v-for="v in notice" :key="v.id">
						<view class="item-box"> </view>
						<view class="item-text">
							<view class="top">
								<text>{{v.noticeTitle}}</text>
							</view>
							<view class="item-state">
								<text>{{v.urgencyName}}</text>
							</view>
							<view class="bottom">
								<text>物业服务中心 {{v.date}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view v-if="current === 2">
				<view class="active-body">
					<view class="active-body-item" v-for="v in notice" :key="v.id">
						<view class="item-box"> </view>
						<view class="item-text">
							<view class="top">
								<text>{{v.noticeTitle}}</text>
							</view>
							<view class="item-state">
								<text>{{v.urgencyName}}</text>
							</view>
							<view class="bottom">
								<text>物业服务中心 {{v.date}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>



	</view>
</template>

<script>
	import {
		http
	} from "../../utils/http.js"
	export default {
		data() {
			return {
				items: ['全部公告', '未读', '已读'],
				current: 0,

				notice: [],
				title: "",
				readState:0,
			};
		},
		methods: {
			onClickItem(e) {
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
				}
				this.getData()
			},

			//数据
			getData() {
				if (this.current == 1) {
					this.readState = 0
				} else if (this.current == 2) {
					this.readState = 1
				} else {
					this.readState = ""
				}
				http({
					url: "/communityAnnouncement/list",
					method: "get",
					params: {
						readState: this.readState
					}
				}).then((res) => {
					console.log(res)
					if (res.code == 0) {
						this.notice = res.data;
					} else {
						console.log("数据接收失败")
					}
			
				})
			
			},
		},
		onLoad() {
			this.getData();
		},
	}
</script>

<style lang="less">
	.home {
		padding: 40rpx;
		display: flex;
		flex-direction: column;

		.button {
			// border: 1px solid red;
			display: flex;
			justify-content: center;
			align-items: center;

			.btn {
				float: left;
				// border: 1px solid blue;
				width: 200rpx;

				.btnHeader {
					height: 60rpx;
					line-height: 60rpx;
					font-size: 28rpx;


				}
			}
		}

		.active-body {
			height: 100%;

			.active-body-item {
				border: 1px solid #e1e1e1;
				border-radius: 8px;
				height: 210rpx;
				margin: 20rpx 0;
				display: flex;
				justify-content: space-evenly;
				align-items: center;
				box-shadow: 0px 0px 15rpx rgba(0, 0, 0, .2);

				.item-box {
					width: 226rpx;
					height: 162rpx;
					background-color: #e6f1ff;
					border-radius: 8px;
					margin: 0 10px;
				}

				.item-text {
					flex: 1;

					.top {
						margin-bottom: 8px;
					}

					.item-state {
						font-size: 28rpx;
						margin-top: -15rpx;
						height: 40rpx;
						width: 130rpx;
						line-height: 40rpx;
						text-align: center;
						color: red;
						background-color: pink;
						border-radius: 5px;
						// border: 1rpx solid red;
					}

					.bottom {
						font-size: 24rpx;
						color: #b8b8b8;
					}
				}
			}
		}
	}
</style>
